# Maintainer: Roberto Catini <roberto.catini@gmail.com>

pkgname=rippled
pkgrel=1
pkgver=0
pkgdesc="Ripple peer-to-peer network daemon"
arch=('i686' 'x86_64')
url="https://github.com/ripple/rippled"
license=('custom:ISC')
depends=('protobuf' 'openssl' 'boost-libs')
makedepends=('git' 'scons' 'boost')
checkdepends=('nodejs')
backup=("etc/$pkgname/rippled.cfg")
source=("git://github.com/ripple/rippled.git#branch=master")
sha512sums=('SKIP')

pkgver() {
	cd "$srcdir/$pkgname"
	git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
}

build() {
	cd "$srcdir/$pkgname"
	scons
}

check() {
	cd "$srcdir/$pkgname"
	npm install
	npm test
	build/rippled --unittest
}

package() {
	cd "$srcdir/$pkgname"
	install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
	install -D build/rippled "$pkgdir/usr/bin/rippled"
	install -D -m644 doc/rippled-example.cfg "$pkgdir/etc/$pkgname/rippled.cfg"
	mkdir -p "$pkgdir/var/lib/$pkgname/db"
	mkdir -p "$pkgdir/var/log/$pkgname"
}
